import Vue from 'vue'
import VueRouter from 'vue-router'
//引入login组件
import Zhuye from '../components/zhuye.vue'
import MLogin from '../components/manager/MLogin.vue'
import TLogin from '../components/teacher/TLogin.vue'
import SLogin from '../components/student/SLogin.vue'
import ManHome from '../components/manager/ManHome.vue'
import TeaHome from '../components/teacher/TeaHome.vue'
import StuHome from '../components/student/StuHome.vue'
import MWelcome from '../components/manager/MWelcome.vue'
import TWelcome from '../components/teacher/TWelcome.vue'
import SWelcome from '../components/student/SWelcome.vue'
import StudentList from '../components/manager/StudentList.vue'
import ClassList from '../components/manager/ClassList.vue'
import TeacherList from '../components/manager/TeacherList.vue'
import EssayList from '../components/manager/EssayList.vue'
import TWorkList from '../components/teacher/WorkList.vue'
import TClassList from '../components/teacher/ClassList.vue'
import TEssayList from '../components/teacher/EssayList.vue'

import SEssayList from '../components/student/EssayList.vue'
import SWorkList from '../components/student/WorkList.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: "/",
    redirect:"/zhuye"
  },
  {
    path: "/zhuye",
    component: Zhuye,
  },
  {
    path: "/mlogin",
    name:'mlogin',
    component: MLogin,
  },
  {
    path: "/tlogin",
  
    component: TLogin,
  },
  {
    path: "/slogin",
    component: SLogin,
  },
  {
    path:"/manhome",
    component:ManHome,
    redirect:"/mwelcome",
    children:[
      {path:"/mwelcome",component:MWelcome},
      {path:"/studentlist",component:StudentList},
      {path:"/classlist",component:ClassList},
      {path:"/teacherlist",component:TeacherList},
      {path:"/essaylist",component:EssayList},
    ]
  },

  {
    path:"/teahome",
    component:TeaHome,
    redirect:"/twelcome",
    children:[
      {path:"/twelcome",component:TWelcome},
      {path:"/tworklist",component:TWorkList},
      {path:"/tclasslist",component:TClassList},
      {path:"/tessaylist",component:TEssayList},
    ]
  },

  {
    path:"/stuhome",
    component:StuHome,
    redirect:"/swelcome",
    children:[
      {path:"/swelcome",component:SWelcome},
      {path:"/sworklist",component:SWorkList},
      {path:"/sessaylist",component:SEssayList},
    ]
  },

]

const router = new VueRouter({
  routes
})
//挂载路由导航守卫
/*router.beforeEach((to,from,next)=>{
if(to.path=='/login') return next();
const userFlag =window.sessionStorage.getItem("user");
if(!userFlag) next();
return next('/login')
})
*/
export default router
